cmake_minimum_required(VERSION 3.10)
project(SiFu_U C)

include("config/taskingc.cmake")

##set(CMAKE_VERBOSE_MAKEFILE ON)

set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)

include_directories(${SRC_DIR})

file(GLOB_RECURSE IncludePath LIST_DIRECTORIES true RELATIVE "${CMAKE_CURRENT_BINARY_DIR}" "include/**$")
list(JOIN IncludePath " -I" IncludePath)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/IncludePath.opt" "-I${IncludePath} ")

add_compile_options(-D__CPU__=tc37x --iso=99 --c++14 --language=+volatile --exceptions --anachronisms --fp-model=3 -O0 --tradeoff=4 --compact-max-size=200 -g -Wc-w544 -Wc-w557 -Ctc37x  -cs --misrac-version=2012 -N0 -Z0 -Y0)
add_compile_options(-fIncludePath.opt)

add_link_options(-lrt -lfp_fpu -lcs_fpu  -Wl-Oc -Wl-OL -Wl-Ot -Wl-Ox -Wl-Oy -Wl-mc -Wl-mf -Wl-mi -Wl-mk -Wl-ml -Wl-mm -Wl-md -Wl-mr -Wl-mu --no-warnings= -Wl--error-limit=42 --exceptions --strict --anachronisms --force-c++ -Ctc37x)
add_link_options(-Wl-obin/${PROJECT_NAME}.hex:IHEX)
add_link_options(--lsl-core=vtc  --lsl-file=${PROJECT_SOURCE_DIR}/config/Lcf_Tasking_Tricore_Tc.lsl)

# 源文件目录
aux_source_directory(${SRC_DIR} DIR_SRCS)

find_library(Infineon_Lib infineon "${PROJECT_SOURCE_DIR}/lib")
find_library(Seekfree_Lib seekfree "${PROJECT_SOURCE_DIR}/lib")
find_library(Peripheral_Lib peripheral "${PROJECT_SOURCE_DIR}/lib")

# 生成可执行文件
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")

add_executable(${PROJECT_NAME} ${DIR_SRCS})
target_link_libraries(${PROJECT_NAME} ${Infineon_Lib} ${Seekfree_Lib} ${Peripheral_Lib})
